{extend name="base/base" /}
{block name="main"}
<style>
.layui-form-pane .layui-form-label{width: 160px;}
.layui-form-pane .layui-input-block{
        margin-left: 160px;
}
</style>
<fieldset class="layui-elem-field layui-field-title">
    <legend>前台配置</legend>
</fieldset>
<div class="layui-row layui-tab-content">
    <div class="layui-col-md6">
        <form class="layui-form layui-form-pane" action="">
            <div class="layui-form-item">
                <label class="layui-form-label">网站标题</label>
                <div class="layui-input-block">
                    <input type="text" name="title" lay-verify="required" placeholder="请输入网站标题"
                           value="{$data.value.title}" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">网站描述</label>
                <div class="layui-input-block">
                    <input type="text" name="desc" lay-verify="required" placeholder="请输入网站描述"
                           value="{$data.value.desc}" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">网站关键词</label>
                <div class="layui-input-block">
                    <input type="text" name="keyword" lay-verify="required" placeholder="请输入网站关键词"
                           value="{$data.value.keyword}" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">网站版权</label>
                <div class="layui-input-block">
                    <input type="text" name="copyright" lay-verify="required" placeholder="请输入版权信息"
                           value="{$data.value.copyright}"  autocomplete="off"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">网站备案号</label>
                <div class="layui-input-block">
                    <input type="text" name="icp" lay-verify="required" placeholder="请输入备案号"
                           value="{$data.value.icp}" autocomplete="off" class="layui-input">
                </div>
            </div>
			
            <div class="layui-form-item">
                <label class="layui-form-label">公安备案</label>
                <div class="layui-input-block">
                    <input type="text" name="icp_ga" lay-verify="required" placeholder="请输入公安备案"
                           value="{$data.value.icp_ga??''}" autocomplete="off" class="layui-input">
                </div>
            </div>
			
            <div class="layui-form-item">
                <label class="layui-form-label">电话</label>
                <div class="layui-input-block">
                    <input type="text" name="tel" lay-verify="required" placeholder="请输入电话"
                           value="{$data.value.tel??''}" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">手机</label>
                <div class="layui-input-block">
                    <input type="text" name="phone" lay-verify="required" placeholder="请输入手机"
                           value="{$data.value.phone??''}" autocomplete="off" class="layui-input">
                </div>
            </div>
			
            <div class="layui-form-item">
                <label class="layui-form-label">邮箱</label>
                <div class="layui-input-block">
                    <input type="text" name="email" lay-verify="required" placeholder="请输入网站关键词"
                           value="{$data.value.email??''}" autocomplete="off" class="layui-input">
                </div>
            </div>
			
            <div class="layui-form-item">
                <label class="layui-form-label">QQ</label>
                <div class="layui-input-block">
                    <input type="text" name="qq" placeholder="请输入QQ"
                           value="{$data.value.qq??''}" autocomplete="off" class="layui-input">
                </div>
            </div>
			
            <div class="layui-form-item">
                <label class="layui-form-label">地址</label>
                <div class="layui-input-block">
                    <input type="text" name="address" lay-verify="required" placeholder="请输入网站关键词"
                           value="{$data.value.address??''}" autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label" style="margin-top: 20px;">logo(202*56)</label>
                <div class="layui-input-block">
                    <img class="layui-upload-img" style="margin-left: 10px;width:250px;" src="{:isset($data.value.logo)?$data.value.logo:''}">
                    <input type="hidden" value="{:isset($data.value.logo)?$data.value.logo:''}" name="logo" lay-verify="">
                    <button type="button" class="layui-btn layui-btn-primary uploadBtn1"><i class="layui-icon">&#xe67c;</i> 上传</button>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label" style="margin-top: 20px;">二维码(100*100)</label>
                <div class="layui-input-block">
                    <img class="layui-upload-img" style="margin-left: 10px;height:50px;" src="{:isset($data.value.ewm)?$data.value.ewm:''}">
                    <input type="hidden" value="{:isset($data.value.ewm)?$data.value.ewm:''}" name="ewm" lay-verify="">
                    <button type="button" class="layui-btn layui-btn-primary uploadBtn2"><i class="layui-icon">&#xe67c;</i> 上传</button>
                </div>
            </div>


          

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <a class="layui-btn" lay-submit lay-filter="save">立即提交</a>
                </div>
            </div>
        </form>
    </div>
</div>


{/block}
{block name="script"}
<script>
    layui.use(['form', 'jquery','upload'], function () {
        var form = layui.form;
        var $ = layui.jquery,upload = layui.upload;

        //上传头像
        upload.render({
            elem: '.uploadBtn1',
            url: "{:url('/admin/upload')}",
            accept:'images',
            acceptMime:'image/*',
            done: function(data){
                var icon=5;
                if(!data.code){
                    icon=6;
                    console.log(this.elem);
                    this.elem.prev().prev().attr('src',data.data.src);
                    this.elem.prev().val(data.data.src);
                }
                layer.msg(data.msg, {icon:icon,time: 1500});
            },
            error: function(){
                layer.msg('上传失败', {icon:icon,time: 1500});
            }
        });
        upload.render({
            elem: '.uploadBtn2',
            url: "{:url('/admin/upload')}",
            accept:'images',
            acceptMime:'image/*',
            done: function(data){
                var icon=5;
                if(!data.code){
                    icon=6;
                    console.log(this.elem);
                    this.elem.prev().prev().attr('src',data.data.src);
                    this.elem.prev().val(data.data.src);
                }
                layer.msg(data.msg, {icon:icon,time: 1500});
            },
            error: function(){
                layer.msg('上传失败', {icon:icon,time: 1500});
            }
        });
        upload.render({
            elem: '.uploadBtn3',
            url: "{:url('/admin/upload')}",
            accept:'images',
            acceptMime:'image/*',
            done: function(data){
                var icon=5;
                if(!data.code){
                    icon=6;
                    console.log(this.elem);
                    this.elem.prev().prev().attr('src',data.data.src);
                    this.elem.prev().val(data.data.src);
                }
                layer.msg(data.msg, {icon:icon,time: 1500});
            },
            error: function(){
                layer.msg('上传失败', {icon:icon,time: 1500});
            }
        });

        //监听提交
        form.on('submit(save)', function (data) {
            var obj = $(this);
            obj.attr("disabled", "disabled").addClass("layui-disabled");
            $.post("{:url('/admin/webconfig')}", data.field, function (data) {
                var icon = 5;
                if (data.code) {
                    icon = 6;
                }
                layer.msg(data.msg, {icon: icon, time: 1500}, function () {
                    if (data.code) {
                        location.reload();
                    } else {
                        obj.removeAttr("disabled").removeClass("layui-disabled");
                    }
                });
            });
            return false;
        });
    });
</script>
{/block}
